
const menuData = [
    {
        name: '测试',
        icon: 'user',
        path: 'mysql',
        children: [
            {
                name: 'index',
                path: 'index',
            },
        ],
    },
    {
        name: '会员管理',
        icon: 'user',
        path: 'membermanage',
        children: [
            {
                name: 'qps',
                path: 'qps',
            },
            {
                name: 'tps',
                path: 'tps',
            }
        ],
    },
];

function formatter(data, parentPath = '/', parentAuthority) {
    return data.map(item => {
        let {path} = item;
        if (!isUrl(path)) {
            path = parentPath + item.path;
        };
        const result = {
                ...item,
                path,
                authority: item.authority || parentAuthority,
            };
        if (item.children) {
            result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
        };
        return result;
    });
}

export const getMenuData = () => formatter(menuData);
